package DomainLayer.Common;

import java.util.ArrayList;
import java.util.Collection;

import Helpers.ApplicationLogger;

public class DomainEntityFactory<T extends AbstractEntity> 
{
	private T entity;
	private Collection<T> entityCollection;
	
	public T getEntityInstance(Class<T> clazz)
	{
		if(entity == null)
		{
			try {
				entity = clazz.newInstance();
			} catch (InstantiationException e) {
				ApplicationLogger.getInstance().LOG.error(e.getMessage());
			} catch (IllegalAccessException e) {
				ApplicationLogger.getInstance().LOG.error(e.getMessage());
				e.printStackTrace();
			}
		}
		return entity;
	}
	
	public Collection<T> getEntityCollectionInstance()
	{
		if(entityCollection == null)
		{
			entityCollection = new ArrayList<T>();
		}
		return entityCollection;
	}
}
